# 作者: 家里蹲 吴越洋
# 2023年03月02日19时47分28秒
import random

class Sort():
    def __init__(self,len):
        self.len=len
        self.arr=[]
        self.arr_random()

    def arr_random(self):
        for i in range(0,self.len):
            self.arr.append(random.randint(0,10000))

    def count_sort(self):
        max_data=max(self.arr)
        arr=[0]*(max_data+1)
        for i in self.arr:
            arr[i]+=1
        j=0
        for i in range(0,max_data+1):
            if arr[i]>0:
                for k in range(0,arr[i]):
                    self.arr[j]=i
                    j+=1

    def bit_map(self):
        int_bit=0
        j=0
        for i in self.arr:
            if 1<<i&int_bit:
                pass
            else:
                int_bit+=1<<i
                print(i,end=' ')
                j+=1
        print('\n')
        print(j)

if __name__ == '__main__':
    sort=Sort(1000)
    sort.count_sort()
    sort.bit_map()